- 
                Notifications
    You must be signed in to change notification settings 
- Fork 6.1k
IsolatedStorageException #18769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IsolatedStorageException #18769
Conversation
method to create directory to prevent IsolatedStorageException tabs to spaces - only to be consistent...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for creating this PR @OzBob
I had one question before we merged this.
        
          
                samples/snippets/csharp/VS_Snippets_CLR/conceptual.isolatedstorage/cs/source.cs
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | The indentation on this has changed too, making the code file incorrectly indented. | 
indenting to 4 spaces CreateFolders function removed, originally to cater for when the filename has a Directory Separator Char in it.
indenting to 4 spaces CreateFolders function removed, originally to cater for when the filename has a Directory Separator Char in it.
indenting to 4 spaces CreateFolders function removed, originally to cater for when the filename has a Directory Separator Char in it.
indenting to 4 spaces CreateFolders function removed, originally to cater for when the filename has a Directory Separator Char in it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving. Bill reviewed and comment was addressed. PR was created before new rules related to PRs and code were created.
| isoStore.CreateFile("AnotherTopLevelDirectory/InsideDirectory"); | ||
| Console.WriteLine("Created directories."); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this change intentional? It removes the "InsideDirectory" and then you try to create a file as a directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is not actually deleted but moved to 2nd last line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @OzBob Sorry about that, I was on vacation. I just got back. What I mean is that the directory "InsideDirectory" doesn't seem to be created anymore? Unless I'm missing something, which is possible.
I just created a test project and ran the original code. It worked as expected:
dotnet run
Created directories.
Created a new file in the root.
Created a new file in the InsideDirectory.
I then ran the code from this PR and it failed:
dotnet run
System.IO.IsolatedStorage.IsolatedStorageException: Operation not permitted on IsolatedStorageFileStream.
 ---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\thrak\AppData\Local\IsolatedStorage\5uysulys.woc\5ou1xfgf.iws\Url.2txcxmkov3cbmd5tmqeaz0ccetpw5zem\Url.2txcxmkov3cbmd5tmqeaz0ccetpw5zem\Files\AnotherTopLevelDirectory\NewFile.txt'.
   at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
   at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.IsolatedStorage.IsolatedStorageFileStream.InitializeFileStream(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, IsolatedStorageFile isf)
   --- End of inner exception stack trace ---
   at System.IO.IsolatedStorage.IsolatedStorageFileStream.InitializeFileStream(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, IsolatedStorageFile isf)
   at System.IO.IsolatedStorage.IsolatedStorageFile.CreateFile(String path)
   at tempcode.Program.Main() in C:\temp\tempcode\Program.cs:line 18
Created directories.
Created a new file in the root.
Unhandled exception. System.IO.IsolatedStorage.IsolatedStorageException: Operation not permitted on IsolatedStorageFileStream.
 ---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\thrak\AppData\Local\IsolatedStorage\5uysulys.woc\5ou1xfgf.iws\Url.2txcxmkov3cbmd5tmqeaz0ccetpw5zem\Url.2txcxmkov3cbmd5tmqeaz0ccetpw5zem\Files\AnotherTopLevelDirectory\InsideDirectory\HereIAm.txt'.
   at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
   at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.IsolatedStorage.IsolatedStorageFileStream.InitializeFileStream(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, IsolatedStorageFile isf)
   --- End of inner exception stack trace ---
   at System.IO.IsolatedStorage.IsolatedStorageFileStream.InitializeFileStream(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, IsolatedStorageFile isf)
   at System.IO.IsolatedStorage.IsolatedStorageFile.CreateFile(String path)
   at tempcode.Program.Main() in C:\temp\tempcode\Program.cs:line 35
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there may have been an error in one of the commits. Asking collaborator for feedback.
| @OzBob This is getting stale. Can you respond to the previous comment? | 
| @OzBob Going to close this soon as abandoned. Just FYI 😄 Please respond, cheers! | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what error is holding this up?
can you suggest how to resolve?
| isoStore.CreateFile("AnotherTopLevelDirectory/InsideDirectory"); | ||
| Console.WriteLine("Created directories."); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is not actually deleted but moved to 2nd last line.
| what does 'project missing' mean in https://github.com/dotnet/docs/pull/18769/checks?check_run_id=994903800? | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code doesn't seem to work as submitted. Please see inline comment.
| 
 This error isn't important for the PR and can be ignored. We've moved to a different snippet processing system and this snippet is part of the old system. We're not requiring community members to create projects (required by the new system) when they are doing minor updates to old snippets. | 
| 
 
 I have a try/catch to prove a point, but the 2nd exception in the inline comment can't be replicated. My last line of code is to write "Created a new file in the root." to the COnsole. There is no code after that. What line of code in your copy of source.cs is causing that exception? | 
| Sorry for the delay. This notification slipped through. Try deleting your isolated storage folder to clear it out. Using the code from your commit: https://github.com/dotnet/docs/blob/bb8865e133e5751407e4eb3ecebf1c4c9e663272/samples/snippets/csharp/VS_Snippets_CLR/conceptual.isolatedstorage/cs/source.cs I get this error: If I run it a second time, I get this error: Here is the code I used. using System;
using System.IO;
using System.IO.IsolatedStorage;
namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly, null, null))
            {
                isoStore.CreateDirectory("TopLevelDirectory");
                isoStore.CreateDirectory("TopLevelDirectory/SecondLevel");
                var isofilename = "AnotherTopLevelDirectory/NewFile.txt";
                try
                {
                    isoStore.CreateFile(isofilename);
                }
                catch (IsolatedStorageException iex)
                {
                    Console.WriteLine(iex.ToString());
                }
                var path = Path.GetDirectoryName(isofilename);
                isoStore.CreateDirectory(path);//Creating "AnotherTopLevelDirectory";
                isoStore.CreateFile(isofilename);//Creating "AnotherTopLevelDirectory/NewFile.txt";
                isoStore.CreateFile("AnotherTopLevelDirectory/InsideDirectory");
                Console.WriteLine("Created directories.");
                isoStore.CreateFile("InTheRoot.txt");
                Console.WriteLine("Created a new file in the root.");
                isoStore.CreateFile("AnotherTopLevelDirectory/InsideDirectory/HereIAm.txt");
                Console.WriteLine("Created a new file in the InsideDirectory.");
            }
        }
    }
} | 
| investigating ... | 
| Closing this as it's gone stale. Feel free to reopen. | 

method to create directory to prevent IsolatedStorageException
tabs to spaces - only to be consistent...
Summary
Isolated storage exception example, and doc change
Fixes #Issue_Number (if available)